﻿<BaseControl:DataControl x:Class="jSLApp.Client.Forms.MusicDetail"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:BaseControl="clr-namespace:jSLCore.Client.Presentation.BaseControl;assembly=jSLCore.Client.Presentation" xmlns:j="clr-namespace:jSLCore.Client.Presentation.Controls;assembly=jSLCore.Client.Presentation" xmlns:jBinding="clr-namespace:jSLCore.Client.Presentation.jBinding;assembly=jSLCore.Client.Presentation" xmlns:Converters="clr-namespace:jSLApp.Client.Converters" xmlns:BaseConverters="clr-namespace:jSLCore.Client.Presentation.jBinding.BaseConverters;assembly=jSLCore.Client.Presentation" xmlns:Security="clr-namespace:jSLApp.Client.Security" xmlns:tk="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Input.Toolkit" xmlns:Controls="clr-namespace:jSLApp.Client.Controls" xmlns:Forms="clr-namespace:jSLApp.Client.Forms" mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400" Icon="../resources/Music.png" Title="Underground" AcceptButtonName="playButton">
    <j:ImageGroupBox ImageSource="../Resources/Music.png" AllowScroll="True">
    	<j:ImageGroupBox.Header>
            <Grid>
                <TextBlock Text="Информация" HorizontalAlignment="Left"/>
                <HyperlinkButton Content="Перейти к списку композиций" Click="GotoList" HorizontalAlignment="Right"/>                
            </Grid>            
        </j:ImageGroupBox.Header>
    	<StackPanel Orientation="Vertical">
            <StackPanel Orientation="Horizontal" Margin="10,10,10,0">
                <j:ImageButton Image="../Resources/PlayMini.png" ToolTipService.ToolTip="Воспроизвести" VerticalAlignment="Center" x:Name="playButton"/>                
                <HyperlinkButton Content="{Binding AuthorName}" FontSize="16" FontWeight="Bold" VerticalAlignment="Center" Click="goto_Author"/>
                <TextBlock Text=" - " FontSize="16" FontWeight="Bold" VerticalAlignment="Center"/>
                <TextBlock Text="{Binding Name}" FontSize="16" FontWeight="Bold" VerticalAlignment="Center" Cursor="Hand" MouseLeftButtonDown="changeName_Clicked">
                    <BaseControl:BaseControl.jBinding>
                        <Converters:IsAuthorizedAuthorBinding ElementPropertyPath="Cursor">                            
                                <Converters:TrueToHandConverter>
                                    <Converters:AuthorIsCurrentUserConverter/>
                                </Converters:TrueToHandConverter>                            
                        </Converters:IsAuthorizedAuthorBinding>
                    </BaseControl:BaseControl.jBinding>
                </TextBlock>
                <HyperlinkButton Content="(Скачать)" Click="download_Clicked">
                    <BaseControl:BaseControl.jBinding>
                        <jBinding:jBooleansBinding Operator="Or">
                            <jBinding:jReadOnlyBinding Path="AllowDownload"/>
                            <Converters:IsAuthorizedAuthorBinding>
                                <Converters:AuthorIsCurrentUserConverter/>
                            </Converters:IsAuthorizedAuthorBinding>
                            <Security:SecurityBinding Permission="ChangeUserEx"/>
                        </jBinding:jBooleansBinding>
                    </BaseControl:BaseControl.jBinding>
                </HyperlinkButton>
            </StackPanel>
            <TextBlock Foreground="Gray" FontSize="13" TextWrapping="Wrap" MaxWidth="500" Margin="20,5,5,5" Cursor="Hand" MouseLeftButtonDown="changeInfo_Clicked">
                <BaseControl:BaseControl.jBinding>
                    <jBinding:jBindingCollection>
                        <Converters:IsAuthorizedAuthorBinding ElementPropertyPath="Cursor">                            
                                <Converters:TrueToHandConverter>
                                    <Converters:AuthorIsCurrentUserConverter/>
                                </Converters:TrueToHandConverter>                            
                        </Converters:IsAuthorizedAuthorBinding>
                        <jBinding:jBooleansBinding Operator="Or">
                            <Converters:IsAuthorizedAuthorBinding/>
                            <jBinding:jReadOnlyBinding Path="Info">
                                <BaseConverters:jInvertBooleanConverter>
                                    <BaseConverters:jIsToStringEquals EqualsTo=""/>
                                </BaseConverters:jInvertBooleanConverter>
                            </jBinding:jReadOnlyBinding>
                        </jBinding:jBooleansBinding>
                    </jBinding:jBindingCollection>                        
                    </BaseControl:BaseControl.jBinding>
            	<TextBlock.Text>
            		<Binding Path="Info">
            			<Binding.Converter>
            				<BaseConverters:jTextIfEmptyStringConverter Text="Нет комментария к композиции"/>
            			</Binding.Converter>
            		</Binding>
            	</TextBlock.Text>
            </TextBlock>
        	<StackPanel Orientation="Horizontal">
                <Image Width="250" Height="250" HorizontalAlignment="Center" Margin="20" MouseLeftButtonDown="changePicture_Clicked">
                    <BaseControl:BaseControl.jBinding>
                        <Converters:IsAuthorizedAuthorBinding ElementPropertyPath="Cursor">                            
                                <Converters:TrueToHandConverter>
                                    <Converters:AuthorIsCurrentUserConverter/>
                                </Converters:TrueToHandConverter>                            
                        </Converters:IsAuthorizedAuthorBinding>
                    </BaseControl:BaseControl.jBinding>
                    <Image.Source>
                        <jBinding:jBinding Path="ImageBs"  ConvertingMode="BinaryToImage"/>
                    </Image.Source>
                </Image>
                <j:ImageGroupBox Header="Управление" MaxWidth="250" Margin="20" x:Name="hdr">
                    <BaseControl:BaseControl.jBinding>
                        <Converters:IsAuthorizedAuthorBinding/>
                    </BaseControl:BaseControl.jBinding>
                    <StackPanel Orientation="Vertical" >                        
                    <j:LeftHeaderContainer Header="Кол-во прослушиваний:" x:Name="test">
                       <BaseControl:BaseControl.jBinding>
                            <Converters:IsAuthorizedAuthorBinding/>
                        </BaseControl:BaseControl.jBinding>
                        <TextBlock Text="{Binding ListenCount}">
                        </TextBlock>
                    </j:LeftHeaderContainer>
                    <j:LeftHeaderContainer Header="Кол-во скачиваний:">
                        <BaseControl:BaseControl.jBinding>
                            <Converters:IsAuthorizedAuthorBinding/>
                        </BaseControl:BaseControl.jBinding>
                        <TextBlock Text="{Binding DownloadCount}">
                        </TextBlock>
                    </j:LeftHeaderContainer>                   
                    <CheckBox Content="Публичный" ToolTipService.ToolTip="Виден ли трек в каталоге" IsChecked="{Binding IsPublic}" Click="publicChange_Clicked">
                        <BaseControl:BaseControl.jBinding>
                            <Converters:IsAuthorizedAuthorBinding/>
                        </BaseControl:BaseControl.jBinding>
                    </CheckBox>
                    <CheckBox Content="Разрешить скачивать" IsChecked="{Binding AllowDownload}" Click="downloadChange_Clicked">
                        <BaseControl:BaseControl.jBinding>
                            <Converters:IsAuthorizedAuthorBinding/>
                        </BaseControl:BaseControl.jBinding>
                    </CheckBox>
                    <j:ImageButton Content="Удалить" Image="../Resources/delete.png" Click="track_delete">
                        <BaseControl:BaseControl.jBinding>
                            <Converters:IsAuthorizedAuthorBinding/>
                        </BaseControl:BaseControl.jBinding>
                    </j:ImageButton>                    
                    <j:HelpBox Text="Название трека, комментарий и картинку можно изменить нажав на них." Margin="0">
                        <BaseControl:BaseControl.jBinding>
                            <Converters:IsAuthorizedAuthorBinding/>
                        </BaseControl:BaseControl.jBinding>                        
                    </j:HelpBox>
                </StackPanel>
                </j:ImageGroupBox>
            </StackPanel>
            <j:ImageGroupBox Header="Оценки">
                <BaseControl:BaseControl.jBinding>
                    <Security:SecurityBinding/>
                </BaseControl:BaseControl.jBinding>
                <StackPanel Orientation="Vertical">
                <j:LeftHeaderContainer Header="Музыкальность:">
                    <tk:Rating IsReadOnly="True" ItemCount="5">
                        <BaseControl:BaseControl.jBinding>
                            <Converters:RatingBinding_RO Path="RateMusic"/>
                        </BaseControl:BaseControl.jBinding>
                    </tk:Rating>
                </j:LeftHeaderContainer>
                <j:LeftHeaderContainer Header="Танцевальность:">
                    <tk:Rating IsReadOnly="True" ItemCount="5">
                        <BaseControl:BaseControl.jBinding>
                            <Converters:RatingBinding_RO Path="RateDance"/>
                        </BaseControl:BaseControl.jBinding>
                    </tk:Rating>
                </j:LeftHeaderContainer>
                <j:LeftHeaderContainer Header="Качество:">
                    <tk:Rating IsReadOnly="True" ItemCount="5">
                        <BaseControl:BaseControl.jBinding>
                            <Converters:RatingBinding_RO Path="RateQuality"/>
                        </BaseControl:BaseControl.jBinding>
                    </tk:Rating>
                </j:LeftHeaderContainer>
                    <j:LeftHeaderContainer Header="Средняя оценка:">
                        <TextBlock>
                            <BaseControl:BaseControl.jBinding>
                                <jBinding:jReadOnlyBinding Path="AverageRate">
                                    <BaseConverters:jStringToFirstNSymbolsConverter ResultStringLength="3"/>
                                    </jBinding:jReadOnlyBinding>
                            </BaseControl:BaseControl.jBinding>
                        </TextBlock>
                    </j:LeftHeaderContainer>
                    <CheckBox Content="Трек готов" Click="setDone_Clicked">                        
                        <BaseControl:BaseControl.jBinding>
                            <jBinding:jBindingCollection>
                                <jBinding:jReadOnlyBinding Path="IsDone"/>
                                <jBinding:jBooleansBinding ElementPropertyPath="IsEnabled" Operator="And">
                                        <Security:SecurityBinding Permission="SetTrackIsDone"/>
                                        <jBinding:jReadOnlyBinding Path="IsDone">
                                            <BaseConverters:jInvertBooleanConverter/>
                                        </jBinding:jReadOnlyBinding>
                                </jBinding:jBooleansBinding>
                            </jBinding:jBindingCollection>
                        </BaseControl:BaseControl.jBinding>
                    </CheckBox>                    
                </StackPanel>
            </j:ImageGroupBox>
            <Forms:SubscriptionToIt x:Name="subs"/>
            <j:LeftHeaderContainer Header="Длина:" >
                <TextBlock>
                	<TextBlock.Text>
                		<jBinding:jBinding>
                			<Binding.Converter>
                				<Converters:MusicToTrackLengthConverter/>
                			</Binding.Converter>
                		</jBinding:jBinding>
                	</TextBlock.Text>
                </TextBlock>
            </j:LeftHeaderContainer>
            <j:LeftHeaderContainer Header="Постоянная ссылка:">
                <HyperlinkButton ToolTipService.ToolTip="Скопировать в буфер обмена" Click="copyLink_Clicked">
                	<HyperlinkButton.Content>
                		<Binding Path="id">
                			<Binding.Converter>
                                <Converters:MusiciDToWebLinkConverter/>
                            </Binding.Converter>
                		</Binding>
                	</HyperlinkButton.Content>
                </HyperlinkButton>
            </j:LeftHeaderContainer>
            <Forms:CommentList IsRatingVisible="True" x:Name="comments" DataUpdated="reloadData_FromComment"/>
        </StackPanel>        
    </j:ImageGroupBox>
</BaseControl:DataControl>
